<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
var appId="";
var timestamp="";
var nonceStr="";
var signature="";
function urlencode(str){
	str=(str+'').toString();
	  return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').  
	    replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');  
}
$.ajax({
	url : '${ctx}/wechatapi/findwx?tt='+Math.random(),
	data : {
		url : window.location.href
	},
	async: false,
	dataType : 'json',
	success : function(result) {
		appId = result.appId;
		timestamp=result.timestamp;
		nonceStr=result.noncestr;
		signature=result.signature;
	}	
});
wx.config({
    debug: false,
    appId: appId,
    timestamp: timestamp,
    nonceStr:  nonceStr,
    signature: signature,
    jsApiList: [
        'checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'hideMenuItems',
        'showMenuItems',
        'hideAllNonBaseMenuItem',
        'showAllNonBaseMenuItem',
        'translateVoice',
        'startRecord',
        'stopRecord',
        'onRecordEnd',
        'playVoice',
        'pauseVoice',
        'stopVoice',
        'uploadVoice',
        'downloadVoice',
        'chooseImage',
        'previewImage',
        'uploadImage',
        'downloadImage',
        'getNetworkType',
        'openLocation',
        'getLocation',
        'hideOptionMenu',
        'showOptionMenu',
        'closeWindow',
        'scanQRCode',
        'chooseWXPay',
        'openProductSpecificView',
        'addCard',
        'chooseCard',
        'openCard'
    ]
});

//新版微信
wx.ready(function () {
	//分享到朋友圈
	wx.onMenuShareTimeline({
	    title: "律林帮欢迎您!", // 分享标题
	    link: 'open.weixin.qq.com/connect/oauth2/authorize?appid='+appId+'&redirect_uri='+urlencode(window.location.href+"?weixin=123")+'&response_type=code&scope=snsapi_userinfo&state=111#wechat_redirect', // 分享链接
		imgUrl: 'http://ym0kf04fm6.proxy.qqbrowser.cc/lvb/static/web/img/icon01.png', // 分享图标
			success: function () { 
			// 用户确认分享后执行的回调函数
			//alert("yes yes");
			},
			cancel: function () { 
			// 用户取消分享后执行的回调函数
			}
	});
	//获取“分享给朋友”按钮点击状态及自定义分享内容接口
	wx.onMenuShareAppMessage({
	    title: '律林帮欢迎您!', // 分享标题
	    desc: '律林帮欢迎您!', // 分享描述
	    link: 'open.weixin.qq.com/connect/oauth2/authorize?appid='+appId+'&redirect_uri='+urlencode(window.location.href+"?weixin=123")+'&response_type=code&scope=snsapi_userinfo&state=111#wechat_redirect', // 分享链接
		imgUrl: 'http://ym0kf04fm6.proxy.qqbrowser.cc/lvb/static/web/img/icon01.png', // 分享图标
	    type: '', // 分享类型,music、video或link，不填默认为link
	    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
		success: function () {
			//alert("ssssss");
		},
		cancel: function () { 
		// 用户取消分享后执行的回调函数
		}
	});
	//分享到qq
	wx.onMenuShareQQ({
	    title: '律林帮欢迎您!', // 分享标题
	    desc: '律林帮欢迎您!', // 分享描述
	    link: 'open.weixin.qq.com/connect/oauth2/authorize?appid='+appId+'&redirect_uri='+urlencode(window.location.href+"?weixin=123")+'&response_type=code&scope=snsapi_userinfo&state=111#wechat_redirect', // 分享链接
		imgUrl: 'http://ym0kf04fm6.proxy.qqbrowser.cc/lvb/static/web/img/icon01.png', // 分享图标		
	      trigger: function (res) {
	          //alert('用户点击分享到QQ');
	        },
	        complete: function (res) {
	          //alert(JSON.stringify(res));
	        },
	        success: function (res) {
	          //alert('已分享');
	        },
	        cancel: function (res) {
	         // alert('已取消');
	        },
	        fail: function (res) {
	         // alert(JSON.stringify(res));
	        }		
	});
	//分享到微博
	wx.onMenuShareWeibo({
	    title: '律林帮欢迎您!', // 分享标题
	    desc: '律林帮欢迎您!', // 分享描述
	    link: 'open.weixin.qq.com/connect/oauth2/authorize?appid='+appId+'&redirect_uri='+urlencode(window.location.href+"?weixin=123")+'&response_type=code&scope=snsapi_userinfo&state=111#wechat_redirect', // 分享链接
		imgUrl: 'http://ym0kf04fm6.proxy.qqbrowser.cc/lvb/static/web/img/icon01.png', // 分享图标		
	      trigger: function (res) {
	          //alert('用户点击分享到QQ');
	        },
	        complete: function (res) {
	          //alert(JSON.stringify(res));
	        },
	        success: function (res) {
	          //alert('已分享');
	        },
	        cancel: function (res) {
	         // alert('已取消');
	        },
	        fail: function (res) {
	         // alert(JSON.stringify(res));
	        }			
	});
	//批量隐藏菜单
	wx.hideMenuItems({
	   menuList: [
          'menuItem:readMode', // 阅读模式
          'menuItem:favorite',//收藏
          'menuItem:share:facebook',//分享到FB
          'menuItem:share:QZone',//分享到 QQ 空间
          'menuItem:editTag',//编辑标签
          'menuItem:delete',//删除
          'menuItem:copyUrl',//复制链接
          'menuItem:originPage',//原网页
          'menuItem:readMode',//阅读模式
          'menuItem:openWithQQBrowser',//在QQ浏览器中打开
          'menuItem:openWithSafari',//在Safari中打开
          'menuItem:share:email',//邮件
          'menuItem:copyUrl' // 复制链接
	   ],
       success: function (res) {
         //alert('已隐藏“阅读模式”，“分享到朋友圈”，“复制链接”等按钮');
       },
       fail: function (res) {
        // alert(JSON.stringify(res));
       }		
	});
});
</script>